Skip to content

feat(memory): add version-aware development history core - #456

Closed
Anduin9527 wants to merge 26 commits into
libra-tools:mainfrom
Anduin9527:codex/memory-m2-core-draft-pr
Closed

Anduin9527 wants to merge 26 commits into
libra-tools:mainfrom
Anduin9527:codex/memory-m2-core-draft-pr

Conversation

@Anduin9527

@Anduin9527 Anduin9527 commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add repository-local, event-sourced Memory storage with immutable revisions, append-only events, CAS-protected refs, and rebuildable SQLite projections.
  • Compile terminal Task and Intent development history into version-bound Episodes with structured evidence.
  • Add deterministic FTS5/BM25 retrieval, Git applicability checks, and audited context injection through context-selection receipts.
  • Expose Memory search/show/status/rebuild commands and Agent Bridge 1.2 integration: audited memory.recall plus opt-in memory.episode.record for completed DSH turns.

Architecture

The implementation follows the design accepted in #454:

  1. Content-addressed objects and the protected Memory ref preserve authoritative history.
  2. SQLite stores rebuildable projections, bounded compiler jobs, FTS5 indexes, and context-selection receipts.
  3. Task Episodes summarize one development task; Intent Episodes pin contributing Task revisions.
  4. Retrieval freezes repository, code, and projection state before ranking and context injection.
  5. DSH capture records canonical Task/Run/Decision/TaskEvent evidence and invokes the existing Episode compiler, admission policy, and writer. The caller cannot choose repository authority or actor identity.

Upstream integration

Merged current upstream main through a4d6ca6b11489e734571cca071dd3dd9aadc5c59 in merge commit 191094fd61d3cbc46a9ffa5785c4d16b7d2a6cee, preserving the existing PR branch history.

  • Honor upstream's removal of the former Code UI, Publish/Worker, Web, MCP, and obsolete operation-wrapper surfaces instead of reviving them during conflict resolution.
  • Preserve current Operation v2 schema, migration, GC, and command behavior.
  • Keep Memory authority local-only across clone, fetch, push, local discovery, branch/update-ref, and symbolic-ref boundaries.
  • Protect the owner-managed memory.keyed_digest.v1 configuration surface.
  • Move the unpublished Memory migrations after the current upstream schema tip:
    • 2026092501_memory_core
    • 2026092502_memory_fts_search
    • 2026092503_context_selection_receipt

The migration runner only applies versions above the current tip. The new ordering prevents repositories already on upstream 2026091901 from skipping Memory tables. Memory SQL semantics are unchanged.

DSH integration

Enable completed-turn capture with LIBRA_DSH_MEMORY_MODEL=deepseek-chat on the bridge and captureMemoryEpisodes: true in the separately maintained DSH plugin. A compiler credential is required. Recall alone remains available without a compiler model.

Capture uses the first-turn code HEAD and completion HEAD, targets that turn's compilation job, and retains SHA-1 code-anchor compatibility. The plugin's real DSH v0.1.2-alpha.1 gate previously generated a structured Episode with a real compiler model, verified its stored projection/receipt, remounted the plugin, and recalled the result through a real headless model run.

The shelved native Libra DSH runtime is not included. The plugin's Cordis refactor is separate preparation work, not part of this PR.

Verification

Checks run in the libra-dev-anduin development container on leris after resolving the merge:

  • cargo +nightly fmt --all --check: passed.
  • cargo check --all-targets --all-features: passed.
  • cargo clippy --all-targets --all-features -- -D warnings: passed.
  • cargo test --test memory_episode_test --test fts5_capability_test -- --test-threads=1: 4 passed.
  • cargo test --test command_test memory -- --test-threads=1: 4 passed.
  • cargo test --lib memory -- --test-threads=1: 146 passed.
  • Built-in migration registry regression: passed with 68 migrations and latest version 2026092503.

The first full cargo test --all -- --test-threads=1 run completed 3,510 library tests: 3,504 passed and 6 failed. Two merge-related failures (Memory operation scope and migration registry expectations) were fixed and passed exact reruns. The remaining four failures were reproduced unchanged on a detached pure upstream/main worktree in the same container: the existing-pack-index assertion, descendant-process cleanup, and two bubblewrap usability checks. The container has a root-owned /usr/bin/bwrap, but Docker does not permit namespace creation. GitHub CI is the authoritative clean-environment result.

Review guide

  1. Migrations, contracts, writer, and projection replay.
  2. Bounded evidence sources, per-root generation jobs, and Episode compilers.
  3. FTS5/BM25 reader, frozen views, and audited context injection.
  4. Bridge session binding, completed-turn capture, code anchors, and Memory CLI.

Memory remains repository-local. Remote Memory publication, the separate DSH plugin refactor, and the shelved native DSH runtime are out of scope.

Refs #451
Builds on #454

Signed-off-by: anduin9527 <anduin9527@gmail.com>
Signed-off-by: anduin9527 <anduin9527@gmail.com>
Signed-off-by: anduin9527 <anduin9527@gmail.com>
Signed-off-by: anduin9527 <anduin9527@gmail.com>
Signed-off-by: anduin9527 <anduin9527@gmail.com>
Signed-off-by: anduin9527 <anduin9527@gmail.com>
Signed-off-by: anduin9527 <anduin9527@gmail.com>
Signed-off-by: anduin9527 <anduin9527@gmail.com>
Signed-off-by: anduin9527 <anduin9527@gmail.com>
Signed-off-by: anduin9527 <anduin9527@gmail.com>
Signed-off-by: anduin9527 <anduin9527@gmail.com>
Signed-off-by: anduin9527 <anduin9527@gmail.com>
Signed-off-by: anduin9527 <anduin9527@gmail.com>
Signed-off-by: anduin9527 <anduin9527@gmail.com>
Signed-off-by: anduin9527 <anduin9527@gmail.com>
Signed-off-by: anduin9527 <anduin9527@gmail.com>
Signed-off-by: anduin9527 <anduin9527@gmail.com>
Signed-off-by: anduin9527 <anduin9527@gmail.com>
Signed-off-by: anduin9527 <anduin9527@gmail.com>
Signed-off-by: anduin9527 <anduin9527@gmail.com>
Restore explicit streamed thinking for Episode compilation and bounded metadata diagnostics. Renew all bridge request deadlines on useful progress while preserving workspace lease durations. Verified with 74 focused Rust tests and cargo clippy --lib -- -D warnings in Docker.

Signed-off-by: anduin9527 <anduin9527@gmail.com>
@Anduin9527
Anduin9527 marked this pull request as ready for review September 9, 2026 03:00
Signed-off-by: Anduin9527 <anduin9527@gmail.com>
Signed-off-by: Anduin9527 <anduin9527@gmail.com>
Signed-off-by: Anduin9527 <anduin9527@gmail.com>
@Anduin9527

Copy link
Copy Markdown
Contributor Author

Closing this revision so we can rebuild the branch on current main, address the final integration review findings, remove CI-scope changes, and resubmit with a clean commit history.

@Anduin9527 Anduin9527 closed this Sep 25, 2026
genedna added a commit that referenced this pull request Oct 7, 2026
…artable candidates

- plan-20260913 (Media) is 实施中, not 未启动: FL-00/01/07/02/06/03/04/05 all done/complete
  (v0.30.0..v0.30.5), only plan-level closure gates remain; fix the earlier 未启动/FL-00-pending rows.
- Next startable candidates (zero internal prereq + review PASS) are plan-20260916 CAP-01
  (must re-verify DEP-CAP-01 monoengine pin) and plan-20260926 DM-00 (DEP-DM-03 #456 clone
  not at expected path; needs clone or explicit downgrade to gh pr diff).
- Note gh auth is available (genedna, repo+workflow scopes).

Signed-off-by: Eli Ma <eli@patch.sh>
genedna added a commit that referenced this pull request Oct 7, 2026
- plan-20260926: DM-00 done/complete. Append '## 取材清单' section with 34-item
  file-level inventory (src/internal/ai/memory/** at pin bc1be58), freeze #456
  remote facts (state=CLOSED, MERGEABLE/UNSTABLE, 149 files, 26 commits, reviews=0)
  at 2026-10-07 01:03 UTC, record migration 2026090701/02/03 skip (tip 2026092701),
  and MemoryAnchorConfidence -> MemoryConfidence (deleted context_budget) note.
- plan-20260819: add retirement banner (M2-01..M2-16E retired, R30 log kept as history).
- plan-status: mark plan-20260819 已取代, plan-20260926 实施中 (DM-00 done), refresh snapshot
  and zero-dependency/pointer rows; DEP-DM-03 satisfied via /tmp/libra-pr456 clone.

Verified: pin rev-parse==bc1be587e4..., inventory rg -c==ls-tree|wc -l==34,
rg plan-20260926 refs present, cargo run status shows only DM-00 write set modified.

Signed-off-by: Eli Ma <eli@patch.sh>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant